package com.example.shaidemo;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import androidx.annotation.NonNull;

public class GongziAdapter extends ArrayAdapter {
    private static final String TAG = "SalaryAdapter";


    public GongziAdapter(@NonNull Context context, int resource, @NonNull List<Gongzi> list) {
        super(context, resource, list);
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View itemView=convertView;
        if(itemView==null){
            itemView= LayoutInflater.from(getContext()).inflate(R.layout.list_item_gongzi_shouye,parent,
                    false);
        }
        Gongzi item=(Gongzi) getItem(position);
        TextView post=(TextView)itemView.findViewById(R.id.post);
        Log.i(TAG, "adapter:post=" + post);
        TextView first_hangye=(TextView)itemView.findViewById(R.id.biaoqian1);
        Log.i(TAG, "adapter:first_hangye=" + first_hangye);
        TextView second_hangye=(TextView)itemView.findViewById(R.id.biaoqian2);
        Log.i(TAG, "adapter:second_hangye=" + second_hangye);
        TextView salary=(TextView)itemView.findViewById(R.id.salary);
        Log.i(TAG, "adapter:salary=" + salary);

        TextView kexindu=(TextView)itemView.findViewById(R.id.tianchong_biaoqian1);
        Log.i(TAG, "adapter:kexindu=" + kexindu);
        TextView gongling=(TextView)itemView.findViewById(R.id.tianchong_biaoqian2);
        Log.i(TAG, "adapter:gongling=" + gongling);


        TextView city=(TextView)itemView.findViewById(R.id.address);
        Log.i(TAG, "adapter:city=" + city);
        TextView gongsi=(TextView)itemView.findViewById(R.id.gongsi);
        Log.i(TAG, "adapter:gongsi=" + gongsi);



        //显示

        post.setText(item.getPost());
        first_hangye.setText(item.getFirst_hangye());
        second_hangye.setText(item.getSecond_hangye());
        salary.setText("￥"+item.getSalary());

        kexindu.setText("可信度："+item.getKexindu());
        gongling.setText("工龄："+item.getGongling()+"年");

        city.setText(item.getCity());
        gongsi.setText(item.getGongsi());

        return itemView;
    }

}
